#include <ros/ros.h>
#include <sensor_msgs/LaserScan.h>

void callback(const sensor_msgs::LaserScan msg)
{
    float middle_distance = msg.ranges[180];
    ROS_INFO("front distance = %f", middle_distance);
}

int main(int argc, char *argv[])
{
    ros::init(argc, argv, "lidar_front_dist");
    ros::NodeHandle nh;
    ros::Subscriber sub = nh.subscribe("/scan", 10, &callback);
    ros::spin();

    return 0;
}
